package com.yuntsg.nnsfcp;

import com.yuntsg.nnsfcp.common.intercepter.ApiSignatureInterceptor;
import com.yuntsg.nnsfcp.service.front.ut.TokenUtils;
import common.util.VerifyUtil;
import org.mybatis.spring.annotation.MapperScan;
import org.mybatis.spring.annotation.MapperScans;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.ServletComponentScan;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.scheduling.TaskScheduler;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;


@SpringBootApplication

/*开始定时任务*/
@EnableScheduling
@MapperScan({"com.yuntsg.nnsfcp", "com.yuntsg.ruiijn"})
@EnableAsync
@ServletComponentScan(basePackages = "com.yuntsg")
@ComponentScan(basePackages = {"common", "com.yuntsg"})
public class NNSFCP extends SpringBootServletInitializer {

    public static void main(String[] args) {
        if (VerifyUtil.isServer()) {
            System.load("/usr/local/share/java/opencv4/libopencv_java480.so");
        }

        SpringApplication.run(NNSFCP.class, args);
    }

    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
        return application.sources(NNSFCP.class);
    }

    @Bean
    public TokenUtils initJwt() {
        return new TokenUtils();
    }

    @Bean
    public ApiSignatureInterceptor initInterceptor() {
        return new ApiSignatureInterceptor();
    }

    @Bean
    public TaskScheduler taskScheduler() {
        ThreadPoolTaskScheduler taskScheduler = new ThreadPoolTaskScheduler();
        taskScheduler.setPoolSize(20);
        return taskScheduler;
    }


}
